/*
 * Copyright (c) 2002-2003 by OpenSymphony
 * All rights reserved.
 */
package org.jackysoft.entity;

import java.util.Collection;
import java.util.Collections;


import org.dom4j.Element;
import org.jackysoft.annotations.Transient;

/**
 * 
 */



public class RestrictionNode extends AbstractNode {
	// ~ Instance fields
	// ////////////////////////////////////////////////////////

	/**
	 * 
	 */
	private static final long serialVersionUID = -5333495419541613819L;
	private ConditionsNode conditions;

	// ~ Constructors
	// ///////////////////////////////////////////////////////////

	public RestrictionNode() {
	}

	public RestrictionNode(org.dom4j.Element element) {
		super(element);
		this.init(element);
	}

	// ~ Methods
	// ////////////////////////////////////////////////////////////////

	@Override
	public Element asElement() {
		Element root = elementof("restrict-to");
		addchild(root, this.conditions);
		return root;
	}

	@Transient
	public Collection<ConditionNode> getAllCondition() {
		if (this.conditions != null) {
			return this.conditions.getConditions();
		}
		return Collections.emptyList();
	}

	
	
	public ConditionsNode getConditions() {
		return conditions;
	}

	@Override
	protected void init(org.dom4j.Element restriction) {
	}

	public void setConditions(ConditionsNode conditions) {
		this.conditions = conditions;
	}

	@Override
	public String tagName() {
		// TODO Auto-generated method stub
		return "restrict-to";
	}

}
